class Solution(object):
    def getRow(self, rowIndex):
        """
        :type rowIndex: int
        :rtype: List[int]
        """
        numRows = rowIndex + 1
        if numRows == 1:
            return [[1]][rowIndex]
        if numRows == 2:
            return [[1], [1, 1]][rowIndex]
        numRows -= 2
        rList = [[1], [1, 1]]
        while numRows > 0:
            newList = [1]
            for i in range(len(rList[-1]) - 1):
                newList.append(rList[-1][i] + rList[-1][i + 1])
            newList.append(1)
            rList.append(newList)
            numRows -= 1
        # return rList
        return rList[rowIndex]


if __name__ == '__main__':
    s = Solution()
    print(s.getRow(1))
